package com.healthmgmt.app.controller;

import com.healthmgmt.app.domain.HeightRecord;
import com.healthmgmt.app.service.IHeightRecordService;
import com.healthmgmt.common.core.controller.BaseController;
import com.healthmgmt.common.core.domain.AjaxResult;
import com.healthmgmt.common.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 身高Controller
 *
 * @author ruoyi
 * @date 2025-06-29
 */
@RestController
@RequestMapping("/app/height-record")
public class HeightRecordController extends BaseController {

    @Resource
    private IHeightRecordService heightRecordService;

    /**
     * 查询身高列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HeightRecord heightRecord)
    {
        startPage();
        List<HeightRecord> list = heightRecordService.selectHeightRecordList(heightRecord);
        return getDataTable(list);
    }

    /**
     * 获取身高详细信息
     */
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(heightRecordService.selectHeightRecordByRecordId(recordId));
    }

    /**
     * 新增身高
     */
    @PostMapping
    public AjaxResult add(@RequestBody HeightRecord heightRecord)
    {
        return toAjax(heightRecordService.insertHeightRecord(heightRecord));
    }

    /**
     * 修改身高
     */
    @PutMapping
    public AjaxResult edit(@RequestBody HeightRecord heightRecord)
    {
        return toAjax(heightRecordService.updateHeightRecord(heightRecord));
    }

    /**
     * 删除身高
     */
    @DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(heightRecordService.deleteHeightRecordByRecordIds(recordIds));
    }
}
